<?php
/**
 * Created by PhpStorm.
 * User: 雷里雷
 * Date: 2018/12/13
 * Time: 19:07
 */

namespace App;

use Illuminate\Database\Eloquent\Model;

class Sentence extends Model
{
    protected $fillable = ['title', 'content', 'source', 'is_original'];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function scopeShow($query, $request)
    {
        return $query->latest()->with('user')->paginate($request->page_size ?? 10)->appends(['page_size' => $request->page_size]);
    }
}